int hammingDistance(int x, int y) {
    int t = x ^y;
    int n = 0;
    while(t) {
        n += t & 1;
        t >>= 1;
    }
    return n;
}
